package test0928.deepcopy;

public class Driver extends Person{

    private Car car;

    public Driver() {
    }

    public Driver(String name, String sex, int age) {
        super(name, sex, age);
    }

    public Driver(String name, String sex, int age, Car car) {
        super(name, sex, age);
        this.car = car;
    }

    public Driver(Driver driver){
        super(driver);
//        this.car = driver.car;//浅拷贝
        this.car=new Car(driver.car);//深拷贝
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    @Override
    public String toString() {
        return "Driver{" +super.toString()+
                "car=" + car +
                '}';
    }
}
